package com.itheima.afternoon.demo04;

import java.util.concurrent.CountDownLatch;

public class Demo {
    public static void main(String[] args) {
        //实际是一个计数器，统计有多少个执行线程，当执行线程结束时唤醒等待线程
        CountDownLatch countDownLatch = new CountDownLatch(3);

        MotherThread m = new MotherThread(countDownLatch);
        m.start();

        ChildThread1 c1 = new ChildThread1(countDownLatch);
        c1.setName("小明");
        ChildThread2 c2 = new ChildThread2(countDownLatch);
        c2.setName("小红");
        ChildThread3 c3 = new ChildThread3(countDownLatch);
        c3.setName("小刚");
        c1.start();
        c2.start();
        c3.start();
    }
}
